#include "../include/head.h"
#include "../lib/error.h"

#define BUFFERSIZE  4096
#define COPYMODE    0644

int main(int agc,char *agv[])
{
	int fd;
	char buf[BUFSIZ];    
	
	if (agc != 2){
		fprintf(stderr,"usage: write0 ttyname\n");
		exit(1);	
	}
	fd = open(agv[1],O_WRONLY);
	if (fd == -1){
		perror(agv[1]);
		exit(1);
	}
	
	while(fgets(buf,BUFSIZ,stdin) != NULL){
		if (write(fd,buf,strlen(buf)) == -1)break;
	}
	close(fd); 

	return 0;
}

    
        
            
        
    

    
        




